#!/bin/bash

server="120.27.68.231"
path="/root/sunbox_tools/appspath/mgt"
user="root"
password="Yanghf*1024"


npm run build || { echo "编译失败！"; exit 1; }

echo "编译成功！，马上开始上传到服务器！"

sleep 1

apppath=$(cd `dirname $0`; pwd)'/dist/*'

appfiles=$(echo $apppath)

expect -c "
spawn scp -r ${appfiles} ${user}@${server}:${path}
expect {
\"*assword\" {set timeout 300; send \"${password}\r\";}
\"yes/no\" {send \"yes\r\"; exp_continue;}
}
expect eof" || { echo "复制文件到服务器失败！"; exit 1; }

echo "发布成功！处理版本更新！"

exit 1;


